/**
 * @file 0502_op_overload.cpp
 * @author Kun (kun_g@msn.com)
 * @brief  测试自定义的运算符()重载
 * @version 0.1
 * @date 2024-06-09
 *
 * @copyright Copyright (c) 2024
 *
 */

#include <iostream>

using namespace std;

class Myfunctor {
public:
  Myfunctor(){};
  Myfunctor(int a) { a_ = a; }

  int operator()(int b) {
    cout << "operator()(int) called " << endl;
    return a_ + b;
  }
  int operator()(int a, int b) {
    cout << "operator()(int,int) called " << endl;
    return a + b;
  }
  int operator()() {
    cout << "operator()() called " << endl;
    return 0;
  }

private:
  int a_ = 0;
};

int main() {
  Myfunctor f(2);
  std::cout << f(3) << std::endl;
  std::cout << f(4, 5) << std::endl;
  std::cout << f() << std::endl;
  return 0;
}